-
-
Notifications
You must be signed in to change notification settings - Fork 227
Redesign client for more flexibility via direct httpx
access
#775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #775 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 49 49
Lines 1971 1971
=========================================
Hits 1971 1971
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This should now be mostly functional, there are definitely some breaking changes in here though. I'd love for folks to take a look around and see if there's anything to improve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One fixed typo in a docstring, other than that looking good!
One suggestion would be to potentially define either a protocol or just a type union e.g. ClientT = Union[Client, AuthenticatedClient]
so that type hinting of "clients" is a bit cleaner, especially if for some reason we add a third client type down the line. May be overkill but would be aesthetically pleasing haha
Co-authored-by: Ethan Mann <[email protected]>
I think we're going to move to dynamically generating clients based on any security schemes defined (rather than the generic, often incorrect, This probably requires some more thought, though, to get the interfaces right 🤔 |
Going to give this a week to marinate in case any of the authors of various issues I've mentioned this in want to give feedback. |
httpx
access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are awesome changes IMO 🎉 Thanks so much @dbanty, and sorry for having a look so late. I mostly went through the generated e2e and integration tests, they look great. Only left one minor comment about customizing the (Authenticated)Client
implementation.
Thanks for all the work getting this off the ground, but I have one concern from reading the changelog which I may have not understood correctly. |
@tasn it really depends on what you're doing 😅. For long-lived clients (i.e., you're reusing the client for many requests), this change will be much more efficient by default as it will reuse TCP connections via connection pooling. For short-lived processes (e.g., a Python script that runs for a few seconds or minutes and then ends), it doesn't matter much if you're not cleaning up, because when the process exits, the connections will be closed. So, while best practice is to close connections either via a context manager or by manually calling So, when do you need to worry (and thus, why did I put warnings in the changelog)? If you have a long lived Python process which creates many clients, each new client will create a new TCP connection. Eventually, if these are not cleaned up, you will run out of available ports on your underlying operating system. Garbage collection doesn't seem to help here, so this could be a big problem. Imagine you have a web server where, for each incoming request, it creates a new So to recap, if you're already keeping a single
|
Closes #118, #202, #491, #532, #745, #773, #775
TODO
base_url
(and similar) duplication requirement